<?php
$phone = $_GET['phone']; //获取传递过来的手机号码参数值

//连接数据库，设置编码等
include_once("../untils/conn.php");

//查询oder表中手机号为$phone的订单信息，并将status和beizhu存为变量
$sql = "SELECT * FROM oder WHERE phone='$phone'";
$result = mysqli_query($con, $sql);

//判断是否查询到数据
if(mysqli_num_rows($result) > 0){
?>
    <html>
    <head>
        <meta charset="utf-8">
        <title>订单查询</title>
        <meta charset="utf-8" />
        <meta content="no-cache,must-revalidate" http-equiv="Cache-Control" />
        <meta content="no-cache" http-equiv="pragma" />
        <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=2.0,minimum-scale=1.0,user-scalable=no;" />
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <meta name="apple-mobile-web-app-status-bar-style" content="black" />
        <meta name="format-detection" content="telephone=no" />
        <link rel="stylesheet" href="/other/odersearch/cx.css">
        <script type="text/javascript" src="/other/odersearch/rem.js"></script>
    </head>
    
    <body>
        <div class="orderlist_tit">订单信息</div>
        <ul class="orderlist_ul" id="orderlist">
<?php
    while($row = mysqli_fetch_assoc($result)){
        $goods = $row['goods'];
        $status = $row['status'];
        $beizhu = $row['beizhu'];
        $name = $row['name'];
        $phone = $row['phone'];
        $sf = $row['sf'];
        $city = $row['city'];
        $xian = $row['xian'];
        $dizhi = $row['dizhi'];
        $time = $row['time'];
        $address = $sf . $city . $xian . $dizhi;
?>
        <li>
            <dt>
                <h1><i><?php echo $goods; ?></i><span>星级服务</span></h1>
                <h2>
                    <?php if($status == 0) { ?>
                        <h2>订单状态：未处理</h2>
                    <?php } elseif($status == 1) { ?>
                        <h2>订单状态：已下单</h2>
                    <?php } elseif($status == 2) { ?>
                        <h2>订单状态：已发货</h2>
                    <?php } elseif($status == 3) { ?>
                        <h2>订单状态：已完成</h2>
                    <?php } elseif($status == 4) { ?>
                        <h2>订单状态：开卡失败</h2>
                    <?php } ?>
                </h2>
                <h2>订单说明：<?php echo $beizhu; ?></h2>
                <h2>收货人：<?php echo $name; ?></h2>
                <h2>收货号码：<?php echo $phone; ?></h2>
                <h2>收货地址：<?php echo $address; ?></h2>
                <h3>下单时间：<?php 
                    $timestamp = $time;
                    $date = date('Y-m-d H:i:s', $timestamp);
                    echo $date; // 输出：2021-07-22 16:52:07
                ?></h3>
            </dt>
        </li>
<?php
    }
?>
        </ul>
    </body>
    </html>
<?php
} else {
?>
    <html>
    <head>
    <meta charset="utf-8">
        <title>订单查询</title>
        <meta charset="utf-8" />
        <meta content="no-cache,must-revalidate" http-equiv="Cache-Control" />
        <meta content="no-cache" http-equiv="pragma" />
        <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=2.0,minimum-scale=1.0,user-scalable=no;" />
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <meta name="apple-mobile-web-app-status-bar-style" content="black" />
        <meta name="format-detection" content="telephone=no" />
    	<link rel="stylesheet" href="/other/odersearch/cx.css">
        
        <script type="text/javascript" src="/other/odersearch/rem.js"></script>
    </head>
    
    <body>
    <div class="orderlist_tit">订单信息</div>
    <ul class="orderlist_ul" id="orderlist">
        <li style="text-align: center;padding-bottom: 10px;padding-top: 10px;">
            没有您的订单信息
        </li>
    </ul>
    </body>
    </html>
<?php
}
?>
